<template>
  <div class="song-list">
    <!-- 歌单详情 -->
    <van-nav-bar
      title="电台详情"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
    />
    <!-- 歌单顶部 -->
    <div id="header">
      <img
        id="header_one"
        :src="song.coverUrl"
        alt=""
        style="width: 150px; height: 150px"
      />
      <span id="header_title"
        ><div>电台节目</div>
        &nbsp;{{ song.name }}
        <span class="num">播放次数：{{ song.listenerCount }}</span></span
      >
    </div>

    <div class="center">
      <span class="center_left"
        ><span>{{ song.categoryName }}</span></span
      >
      <span class="center_right">{{ song.brand }}</span>
    </div>

    <div class="js">
      <span id="js_header">介绍：</span>{{ song.description }}
    </div>
    <!-- 歌曲列表 -->

    <ul id="list" ref="content">
      <div class="song_list">
        节目歌单列表 &nbsp;（{{ song.songs.length }}首歌）
      </div>
      <li v-for="(item, index) in song.songs" :key="index">
        <div class="cover">
          <span class="cover_id">{{ index + 1 }}</span>
          <span class="cover_list">{{ item.name }}</span>
          <!-- <span>{{ item.artists.name }}</span> -->
        </div>
      </li>
    </ul>
  </div>
</template>
  
  <script>
export default {
  data() {
    return {
      song: {
        coverUrl: "",
        name: "",
        description: "",
        songs: {
          artists: [],
        },

        brand: "",
        listenerCount: "",
        categoryName: "",
        artists: [],
      },
    };
  },
  created() {
    this.getListData();
  },
  methods: {
    getListData() {
      this.$request(
        "get",
        "/dj/program/detail?id=" + this.$route.params.id
      ).then((result) => {
        console.log(result);
        this.songlist = result.program.songs;
        this.song.coverUrl = result.program.coverUrl;
        this.song.name = result.program.name;
        this.song.description = result.program.description;
        this.song.songs = result.program.songs;
        this.song.brand = result.program.dj.brand;
        this.song.listenerCount = result.program.listenerCount;
        this.song.categoryName = result.program.categoryName;
        this.song.artists = result.program.songs.artists;
        this.song.songs.artists = result.program.songs.artists;
      });
    },
    onClickLeft() {
      this.$router.go(-1);
    },
    onLoad() {
      // 异步更新数据
      // setTimeout 仅做示例，真实场景中一般为 ajax 请求
      setTimeout(() => {
        this.list = this.list.concat(this.songlist.splice(0, 10));

        // 加载状态结束
        this.loading = false;

        // 数据全部加载完成
        if (this.list.length >= this.songnum) {
          this.finished = true;
        }
      }, 1000);
    },
  },
};
</script>
  
  <style  scoped>
* {
  width: 90%;
}
#header {
  display: float;
  margin: 0 auto;
  width: 90%;
  height: 200px;
}
#header_one {
  float: left;
  width: 50%;
  padding-top: 20px;
  margin: auto;
}
#header_title {
  float: right;
  width: 50%;
  text-align: left;
  height: 150px;
  padding-top: 20px;
}
#header_title > div {
  width: 100px;
  font-size: 24px;
  text-align: left;
  background-color: red;
  border-radius: 5px;
  margin-bottom: 10px;
}
.num {
  padding-top: 10px;
  display: block;
}
.center {
  display: float;
  width: 100%;
  height: 10px;
}
.center_left {
  float: left;
  width: 30%;
  text-align: center;
  color: red;
}
.center_left > span {
  border: 1px solid red;
}
.center_right {
  float: right;
  width: 70%;
  text-align: left;
}
.js {
  margin-top: 50px;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  text-align: center;
}
.song_list {
  margin-left: 5%;
  border: 1px solid rgb(255, 255, 255);
  background: rgb(211, 209, 209);
  text-align: left;
  margin-top: 20px;
}
.cover {
  display: float;
  height: 20px;
  margin-left: 5%;
  text-align: left;
}
.cover_id {
  float: left;
  width: 20%;
  text-align: center;
  border: 1px solid rgb(255, 255, 255);
}
.cover_list {
  float: left;
  width: 75%;
  text-align: left;
}
</style>
  